Skip to content

fix: add integral-based deflection calculations to mass_via_integral scripts#17

Merged
Jammy2211 merged 1 commit intomainfrom
feature/deflections-integral-fix
Apr 9, 2026
Merged

fix: add integral-based deflection calculations to mass_via_integral scripts#17
Jammy2211 merged 1 commit intomainfrom
feature/deflections-integral-fix

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

PR PyAutoLabs/PyAutoGalaxy#324 removed deflections_2d_via_integral_from methods from PyAutoGalaxy but only copied the integrand functions to the mass_via_integral scripts — not the actual scipy.integrate.quad computation loops. This adds the missing integral wrappers so each script computes deflections via numerical integration and compares against the library's analytic/CSE/MGE methods.

Also adds all missing integral functions to gnfw.py and gnfw_virial_mass_conc.py that were never copied from the PR.

Scripts Changed

  • scripts/mass_via_integral/gaussian.py — added deflections_2d_via_integral_from wrapper, updated 4 configs to compare integral vs analytic
  • scripts/mass_via_integral/sersic.py — added integral wrapper, updated 2 configs to compare integral vs CSE
  • scripts/mass_via_integral/sersic_gradient.py — added integral wrapper, updated 2 configs to compare integral vs CSE
  • scripts/mass_via_integral/nfw.py — added deflection and potential integral wrappers, updated 4 configs to compare integral vs analytic
  • scripts/mass_via_integral/gnfw.py — added all missing integral functions (tabulate_integral, surface_density_integrand, gnfw_deflection_func, gnfw_potential_func, deflection_func_sph) plus wrappers for elliptical/spherical deflections and potential, updated 8 configs
  • scripts/mass_via_integral/gnfw_virial_mass_conc.py — added spherical integral functions and wrapper, updated 1 config

Test Plan

  • All 21 mass_via_integral tests pass (integral results match library methods within rtol=1e-3)
  • Smoke tests pass with PYAUTOFIT_TEST_MODE=1

🤖 Generated with Claude Code

…scripts

PR #324 removed deflections_2d_via_integral_from methods from PyAutoGalaxy
but only copied the integrand functions to these scripts, not the actual
quad-based computation loops. This adds the missing integral wrappers so
each script computes deflections via scipy.integrate.quad and compares
against the library's analytic/CSE/MGE methods.

Also adds all missing integral functions to gnfw.py and
gnfw_virial_mass_conc.py (tabulate_integral, surface_density_integrand,
gnfw_deflection_func, gnfw_potential_func, deflection_func_sph).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit 58e6c8e into main Apr 9, 2026
@Jammy2211 Jammy2211 deleted the feature/deflections-integral-fix branch April 9, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant